package servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import common.ServerResponse;
import entity.User;
import service.IUserService;
import service.impl.UserServiceImpl;
import util.JSONUtil;

@WebServlet("/registerServlet")
public class RegisterServlet extends HttpServlet {

	private IUserService userService = new UserServiceImpl();

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		String method = req.getParameter("method");
		switch (method) {
		case "register":
			register(req, resp);
			break;
		default:
			break;
		}
	}

	private void register(HttpServletRequest req, HttpServletResponse resp) throws IOException {

		String name = req.getParameter("name");
		String password = req.getParameter("password");
		User user = userService.register(name, password);
	}

	
}
